package main

import (
    "flag"
    "log"
    "adkr/pkg/turritopsis"
)

func main() {
	var sid string
	var pid, n, f, epochs int
	flag.StringVar(&sid, "sid", "turritopsis", "session id")
	flag.IntVar(&pid, "pid", 0, "process id")
	flag.IntVar(&n, "n", 4, "number of nodes")
	flag.IntVar(&f, "f", 1, "faults")
	flag.IntVar(&epochs, "epochs", 1, "epochs to run")
    var acsSel string
    var krSel string
    flag.StringVar(&acsSel, "acs", "stub", "ACS source: stub|external")
    flag.StringVar(&krSel, "kr", "off", "Key refresh: off|single|external")
    flag.Parse()

	logger := log.Default()

	// Placeholder hooks to be wired by integrator
	cfg := turritopsis.Defaults()
	cfg.SID = sid
	cfg.PID = pid
	cfg.N = n
	cfg.F = f
	cfg.Epochs = epochs

    // Wire ACS by selection (default: stub)
    switch acsSel {
    case "stub":
        cfg.ACS = turritopsis.StubACS(logger)
    case "external":
        // external integrator should set cfg.ACS before Run (left intentionally blank)
    default:
        logger.Printf("unknown --acs=%s", acsSel)
        return
    }

    // Wire KR by selection (default: off)
    switch krSel {
    case "off":
        cfg.KeyRefreshOne = nil
    case "single":
        logger.Printf("--kr=single requires caller-provided channels/config; please integrate via MakeSingleRoundKRViaHigh or NewKeyRefreshFuncUsingChannels in your embedding")
    case "external":
        // external integrator should set cfg.KeyRefreshOne prior to Run
    default:
        logger.Printf("unknown --kr=%s", krSel)
        return
    }

	proto := turritopsis.New(cfg, logger)
	if err := proto.Run(); err != nil {
		logger.Printf("Turritopsis failed: %v", err)
	}
}


